﻿using System;
using UnityEngine;
using UnityEngine.EventSystems;

namespace Studio
{
	// Token: 0x020004BA RID: 1210
	public class GuideBase : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IBeginDragHandler, IDragHandler, IEndDragHandler, IEventSystemHandler
	{
		// Token: 0x17000369 RID: 873
		// (get) Token: 0x06001E95 RID: 7829 RVA: 0x000BFE04 File Offset: 0x000BE004
		public Material material
		{
			get
			{
				return (!this.renderer) ? null : this.renderer.material;
			}
		}

		// Token: 0x1700036A RID: 874
		// (get) Token: 0x06001E96 RID: 7830 RVA: 0x000BFE28 File Offset: 0x000BE028
		// (set) Token: 0x06001E97 RID: 7831 RVA: 0x000BFE30 File Offset: 0x000BE030
		public bool draw
		{
			get
			{
				return this.m_Draw;
			}
			set
			{
				if (Utility.SetStruct<bool>(ref this.m_Draw, value))
				{
					if (this.renderer)
					{
						this.renderer.enabled = this.m_Draw;
					}
					if (this.collider)
					{
						this.collider.enabled = this.m_Draw;
					}
				}
			}
		}

		// Token: 0x06001E98 RID: 7832 RVA: 0x000BFE90 File Offset: 0x000BE090
		protected Color ConvertColor(Color _color)
		{
			_color.r *= 0.75f;
			_color.g *= 0.75f;
			_color.b *= 0.75f;
			_color.a = 0.25f;
			return _color;
		}

		// Token: 0x1700036B RID: 875
		// (set) Token: 0x06001E99 RID: 7833 RVA: 0x000BFEE4 File Offset: 0x000BE0E4
		protected Color colorNow
		{
			set
			{
				if (this.material)
				{
					this.material.color = value;
				}
			}
		}

		// Token: 0x1700036C RID: 876
		// (get) Token: 0x06001E9A RID: 7834 RVA: 0x000BFF04 File Offset: 0x000BE104
		// (set) Token: 0x06001E9B RID: 7835 RVA: 0x000BFF0C File Offset: 0x000BE10C
		public bool isDrag { get; private set; }

		// Token: 0x1700036D RID: 877
		// (get) Token: 0x06001E9C RID: 7836 RVA: 0x000BFF18 File Offset: 0x000BE118
		// (set) Token: 0x06001E9D RID: 7837 RVA: 0x000BFF20 File Offset: 0x000BE120
		public GuideObject guideObject { get; set; }

		// Token: 0x06001E9E RID: 7838 RVA: 0x000BFF2C File Offset: 0x000BE12C
		public void OnPointerEnter(PointerEventData eventData)
		{
			if (Singleton<GuideObjectManager>.Instance.isOperationTarget)
			{
				return;
			}
			this.colorNow = this.colorHighlighted;
		}

		// Token: 0x06001E9F RID: 7839 RVA: 0x000BFF4C File Offset: 0x000BE14C
		public void OnPointerExit(PointerEventData eventData)
		{
			if (!this.isDrag)
			{
				this.colorNow = this.colorNormal;
			}
		}

		// Token: 0x06001EA0 RID: 7840 RVA: 0x000BFF68 File Offset: 0x000BE168
		public virtual void OnBeginDrag(PointerEventData eventData)
		{
			this.isDrag = true;
			Singleton<GuideObjectManager>.Instance.operationTarget = this.guideObject;
		}

		// Token: 0x06001EA1 RID: 7841 RVA: 0x000BFF84 File Offset: 0x000BE184
		public virtual void OnDrag(PointerEventData eventData)
		{
		}

		// Token: 0x06001EA2 RID: 7842 RVA: 0x000BFF88 File Offset: 0x000BE188
		public virtual void OnEndDrag(PointerEventData eventData)
		{
			this.isDrag = false;
			this.colorNow = this.colorNormal;
			Singleton<GuideObjectManager>.Instance.operationTarget = null;
		}

		// Token: 0x06001EA3 RID: 7843 RVA: 0x000BFFA8 File Offset: 0x000BE1A8
		private void OnDisable()
		{
			this.colorNow = this.colorNormal;
		}

		// Token: 0x06001EA4 RID: 7844 RVA: 0x000BFFB8 File Offset: 0x000BE1B8
		public virtual void Start()
		{
			this.renderer = base.gameObject.GetComponent<Renderer>();
			if (this.renderer == null)
			{
				this.renderer = base.gameObject.GetComponentInChildren<Renderer>();
			}
			this.collider = this.renderer.GetComponent<Collider>();
			this.colorNormal = this.ConvertColor(this.material.color);
			this.colorHighlighted = this.material.color;
			this.colorHighlighted.a = 0.75f;
			if (this.renderer)
			{
				this.renderer.enabled = this.m_Draw;
			}
			if (this.collider)
			{
				this.collider.enabled = this.m_Draw;
			}
			this.colorNow = this.colorNormal;
			this.isDrag = false;
		}

		// Token: 0x040020AC RID: 8364
		[SerializeField]
		protected Color colorNormal;

		// Token: 0x040020AD RID: 8365
		[SerializeField]
		protected Color colorHighlighted;

		// Token: 0x040020AE RID: 8366
		protected Renderer renderer;

		// Token: 0x040020AF RID: 8367
		protected Collider collider;

		// Token: 0x040020B0 RID: 8368
		private bool m_Draw = true;
	}
}
